package fun.qu_an.minecraft.gitfetch;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class GitFetch implements ModInitializer {
	public static final String MOD_ID = "git_fetch";
	private static final Logger LOGGER = LogManager.getLogger();

	@Override
	public void onInitialize() {
		ServerLifecycleEvents.SERVER_STARTING.register(server -> {
			try {
				GitFetchConfig.reload(server);
			} catch (Exception e) {
				LOGGER.warn(e.getMessage());
			}
		});
		CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> GitCommand.register(dispatcher));
	}
}
